<?php 

define('__ROOT__', dirname(dirname(__FILE__))); 
require('/home/freshbuzzing/www/140dev/db/140dev_config.php'); 
require('/home/freshbuzzing/www/140dev/db/db_lib.php'); 

$oDB = new db;

if(!$oDB)
{
	die('Could not connect: ' . mysql_error());
}

$result_log = 'OK';

$result = $oDB->select("SELECT DS_PROCESS_NAME,'ERRORES', count(*) FROM LOGS_DETAILS_PROCESS WHERE DS_LOG_TYPE='ERROR' AND DT_EVENT >= DATE(NOW()) GROUP BY DS_PROCESS_NAME ");
	
$str_html = "";

while($row = mysqli_fetch_row($result))
{		
	$str_html = $str_html . "PROCESO: " . $row[0] . ", ERRORES: " . $row[2] . "<BR>";
	
}

//vars
$subject = "Procesos - SCRAPY ";

	
$to = explode(',', "info@sygnium.com" );

$from = "info@sygnium.com";

//Headers
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <info@sygnium.com>" ;

//send for each mail
foreach($to as $mail){
   mail($mail, $subject, $str_html, $headers);
}

/*
// Get User ID
$user = $facebook->getUser();


if ($user) {
  try {
    // Proceed knowing you have a logged in user who's authenticated.
    $user_profile = $facebook->api('/me','GET');
	echo "Name: " . $user_profile['name'];
 } catch (FacebookApiException $e) {
     $login_url = $facebook->getLoginUrl(); 
     echo 'Please eg <a href="' . $login_url . '">login.</a>';
     error_log($e->getType());
     error_log($e->getMessage());
  }
}
else{
	// No user, print a link for the user to login
	$params = array(
  'scope' => 'read_stream, friends_likes'
	);
      $login_url = $facebook->getLoginUrl($params);
      echo 'Please <a href="' . $login_url . '">login.</a>';
}
*/
?>